Introduce a process-wide singleton engine for .collect(engine="gpu")#22410
Conversation
7e6beeb to
0fb9fe8
Compare
| Because each call forks a new child, process-wide side-effects | ||
| (the ``_bind_done`` flag, CPU affinity, environment variables) never | ||
| leak between tests or back into the pytest process. | ||
| def _run_in_subprocess(target: Callable[[], None]) -> None: |
There was a problem hiding this comment.
This PR exposed some issues with the "fork" approach, so we now use "spawn" instead. Otherwise, the tests remain the same.
Co-authored-by: Lawrence Mitchell <wence@gmx.li>
TomAugspurger
left a comment
There was a problem hiding this comment.
Partial review. I'll try to get back to this later, but don't wait for me.
| streaming runtime. | ||
| * ``Cluster.DASK`` : Multi-GPU execution via Dask workers and the rapidsmpf | ||
| streaming runtime. | ||
| * ``Cluster.DEFAULT_SINGLETON`` : Single-GPU execution via the DefaultSingletonEngine. |
There was a problem hiding this comment.
Let's confirm this is the name we want.
- if we ever change the default, then this name will become misleading
- How commonly understood is "singleton"?
- This name doesn't mention "single" GPU-only, though the docs do.
And given that this is the default... maybe we can get away with updating the call sites to cluster: Cluster | None? And if we encounter None then we set up the default singleton cluster, and so we don't even need an enum name for this thing?
There was a problem hiding this comment.
I guess you are right, but I still prefer the more descriptive name. I like DEFAULT_SINGLETON and DefaultSingletonEngine because that is exactly what they are :)
If we ever decide to change the default implementation, I think we should change what DefaultSingletonEngine does internally rather than route the default path to an entirely different engine type.
To me, the important semantic is “process-wide implicit singleton default engine”, and the current name makes that very explicit.
…/default_singleton_engine.py Co-authored-by: Lawrence Mitchell <wence@gmx.li>
|
/merge |
rapidsai#22410) `lf.collect(engine="gpu")` and `pl.GPUEngine(executor="streaming")` using the default cluster now route through a new process-wide `DefaultSingletonEngine` instead of constructing a fresh rapidsmpf `Context`, RMM adaptor, and Python executor for every query. Bootstrap now happens once per process rather than once per query. `DefaultSingletonEngine` is a process-wide single-GPU singleton specialization of `SPMDEngine`: at most one live instance exists per process, it always uses a single-rank communicator plus default environment-derived settings, and repeated calls reuse the same engine instance until explicit shutdown. The default cluster enum value is renamed from `Cluster.SINGLE` to `Cluster.DEFAULT_SINGLETON` so the dispatch token better reflects the actual behavior. This PR also removes the dead inline-context fallback in `evaluate_pipeline`, which was the original `"single"` execution path. Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Lawrence Mitchell (https://github.com/wence-) URL: rapidsai#22410
rapidsai#22410) `lf.collect(engine="gpu")` and `pl.GPUEngine(executor="streaming")` using the default cluster now route through a new process-wide `DefaultSingletonEngine` instead of constructing a fresh rapidsmpf `Context`, RMM adaptor, and Python executor for every query. Bootstrap now happens once per process rather than once per query. `DefaultSingletonEngine` is a process-wide single-GPU singleton specialization of `SPMDEngine`: at most one live instance exists per process, it always uses a single-rank communicator plus default environment-derived settings, and repeated calls reuse the same engine instance until explicit shutdown. The default cluster enum value is renamed from `Cluster.SINGLE` to `Cluster.DEFAULT_SINGLETON` so the dispatch token better reflects the actual behavior. This PR also removes the dead inline-context fallback in `evaluate_pipeline`, which was the original `"single"` execution path. Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Lawrence Mitchell (https://github.com/wence-) URL: rapidsai#22410
rapidsai#22410) `lf.collect(engine="gpu")` and `pl.GPUEngine(executor="streaming")` using the default cluster now route through a new process-wide `DefaultSingletonEngine` instead of constructing a fresh rapidsmpf `Context`, RMM adaptor, and Python executor for every query. Bootstrap now happens once per process rather than once per query. `DefaultSingletonEngine` is a process-wide single-GPU singleton specialization of `SPMDEngine`: at most one live instance exists per process, it always uses a single-rank communicator plus default environment-derived settings, and repeated calls reuse the same engine instance until explicit shutdown. The default cluster enum value is renamed from `Cluster.SINGLE` to `Cluster.DEFAULT_SINGLETON` so the dispatch token better reflects the actual behavior. This PR also removes the dead inline-context fallback in `evaluate_pipeline`, which was the original `"single"` execution path. Authors: - Mads R. B. Kristensen (https://github.com/madsbk) Approvers: - Lawrence Mitchell (https://github.com/wence-) URL: rapidsai#22410
lf.collect(engine="gpu")andpl.GPUEngine(executor="streaming")using the default cluster now route through a new process-wideDefaultSingletonEngineinstead of constructing a fresh rapidsmpfContext, RMM adaptor, and Python executor for every query. Bootstrap now happens once per process rather than once per query.DefaultSingletonEngineis a process-wide single-GPU singleton specialization ofSPMDEngine: at most one live instance exists per process, it always uses a single-rank communicator plus default environment-derived settings, and repeated calls reuse the same engine instance until explicit shutdown.The default cluster enum value is renamed from
Cluster.SINGLEtoCluster.DEFAULT_SINGLETONso the dispatch token better reflects the actual behavior.This PR also removes the dead inline-context fallback in
evaluate_pipeline, which was the original"single"execution path.